<?php


namespace app\tools;

use think\facade\Config;

class ResponseTool
{
    /**
     * 获取默认返回信息
     * @param string $stat 预定义的状态
     * @param array  $data 预定义数据
     * @param string $msg  预定义msg
     * */
    public static function getRs(string $stat, ?array $data = [], ?string $msg = '') {
        $obj = Config::get('statcode');
        $response['code'] = $obj[$stat]['code'];
        $response['msg'] = $msg == '' ? $obj[$stat]['msg'] : $msg;
        $response['data'] = $data;
        return json($response);
    }

}